package com.example.springmvcproject.Controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import com.example.springmvcproject.Service.Inteface.CreditService;
import com.example.springmvcproject.Utils.ResultMessage;
import com.example.springmvcproject.Vo.CreditDelVo;
import com.example.springmvcproject.Vo.CreditSelectiveVo;
import com.example.springmvcproject.Vo.CreditUpVo;
import com.example.springmvcproject.Vo.CreditVo;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/credit")
@CrossOrigin
public class CreditController {
    @Resource
    CreditService creditService;

    @SaCheckLogin
    @RequestMapping("/addCredit")
    public ResultMessage addCredit(@RequestBody @Validated CreditVo creditVo){
        return creditService.addCredit(creditVo);
    }

    @SaCheckLogin
    @RequestMapping("/selectCreditsBySelective")
    public ResultMessage selectCreditsBySelective(@RequestBody @Validated CreditSelectiveVo creditSelectiveVo){
        return creditService.selectCreditsBySelective(creditSelectiveVo);
    }
    @SaCheckLogin
    @RequestMapping("/deleteCreditById")
    public ResultMessage deleteCreditById(@RequestBody @Validated CreditDelVo creditDelVo){
        return creditService.deleteCreditById(creditDelVo);
    }
    @SaCheckLogin
    @RequestMapping("/updateStatusByIdAndNum")
    public ResultMessage updateStatusByIdAndNum(@RequestBody @Validated CreditUpVo creditUpVo){
        return creditService.updateStatusByIdAndNum(creditUpVo);
    }


}
